//
//  UIBarButtonItem+Item.m
//  微博
//
//  Created by MS on 15-12-4.
//  Copyright (c) 2015年 MS. All rights reserved.
//

#import "UIBarButtonItem+Item.h"

@implementation UIBarButtonItem (Item)
+(UIBarButtonItem *)barButtonItemWithImage:(UIImage *)image andHighImage:(UIImage *)highImage target:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents
{
    
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [btn setImage:image forState:UIControlStateNormal];
    [btn setImage:highImage forState:UIControlStateHighlighted];
    btn.contentEdgeInsets = UIEdgeInsetsMake(0, -15, 0, -15);
//    [btn setBackgroundImage:image forState:UIControlStateNormal];
//    [btn setBackgroundImage:highImage forState:UIControlStateHighlighted];
    
//    btn.frame = CGRectMake(0, 0, 40, 40);
    [btn sizeToFit];
    
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
   return  [[UIBarButtonItem alloc] initWithCustomView:btn];

}

@end
